#!/bin/bash

set -e

if [[ -n "${RASTER_VISION_DEBUG}" ]]; then
    set -x
fi

function usage() {
    echo -n \
         "Usage: $(basename "$0")
Attempts to setup the project's development environment.
"
}

if [ "${BASH_SOURCE[0]}" = "${0}" ]
then
    if [ "${1:-}" = "--help" ]
    then
        usage
    else
        # Ensure that a directory exists to house AWS profiles.
        mkdir -p "${HOME}/.aws"

        # Install prerequisites required for Vagrant to provision
        # the virtual machine.
        pip install -r requirements.txt
        vagrant up --provision
        vagrant ssh -c "unset AWS_PROFILE && aws --profile raster-vision configure"
        vagrant ssh -c "cd /vagrant && ./scripts/update"
    fi
fi
